package visualcbir.gui;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JToolBar;
import visualcbir.DlgAboutBox;
import visualcbir.Principal;
import visualcbir.format.DlgHelp;

/**
 *
 * @author sheila
 */
public class ToolBarNorth extends JToolBar implements ActionListener{
    
    VCButton bhNew = new VCButton("img/newFile.png", "New","Crear Nuevo Archivo");
    VCButton bhOpen = new VCButton("img/openFile.png", "Open","Open File");
    VCButton bhSave = new VCButton("img/saveFile.png", "Save","Save File");
    VCButton bhClose = new VCButton("img/closeFile.png", "Close","Close File");
    //Boton bhdeletenode = new Boton("img/eliminar.png", "Eliminar Clase","Eliminar Clase");
    //Boton bhdeleteedge = new Boton("img/modificar.png", "Elminar Relacion","Eliminar Relacion");
    //Boton bhsalida = new Boton("img/evaluar.png", "Obtener Productividad","Ver Resultado ");
    VCButton bhUndo = new VCButton("img/undo.png", "Deshacer","Deshace la ultima acci�n");
    VCButton bhRedo = new VCButton("img/redo.png", "Rehacer","Rehace la ultima accion");
    //BtnSelf bhGraphFactory= new BtnSelf("img/help.png", "Nueva Fabrica","cambia la apariencia");
    VCButton bhHelp= new VCButton("img/help.png", "Help","Help");
    VCButton bhAbout= new VCButton("img/about.png", "About","About...");

    public  ToolBarNorth(){
        super();
        jbInitBar();
    }

    private void jbInitBar()
    {
        this.add(bhNew);
        this.add(bhOpen);
        this.add(bhSave);
        this.add(bhClose);
        //add(bhdeletenode);
        //add(bhdeleteedge);
        this.add(bhUndo);
        //add(bhGraphFactory);        
        this.add(bhHelp);
        this.add(bhAbout);

        //********************* Action Listeners ***************************//
        bhNew.addActionListener(this);
        bhOpen.addActionListener(this);
        bhSave.addActionListener(this);
        bhClose.addActionListener(this);
        bhAbout.addActionListener(this);
        bhHelp.addActionListener(this);
        /*
        bhdeletenode.addActionListener(this);
        bhdeleteedge.addActionListener(this);
        bhundo.addActionListener(this);
        bhredo.addActionListener(this);
        //btnsalida.addActionListener(this)
        
        bhGraphFactory.addActionListener(this);
       */
        
  }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource().equals(bhAbout))
            bmOpenAbout(e);
        if(e.getSource().equals(bhClose))
            System.exit(1);
        if(e.getSource().equals(bhHelp))
            bmHelp();

    }
     public void bmOpenAbout(ActionEvent e) {
      DlgAboutBox dlg = new DlgAboutBox();
      dlg.setLocationRelativeTo(Principal.getInstance());
      dlg.setModal(true);
      dlg.pack();
      dlg.setVisible(true);
    }

     public void bmHelp(){
         DlgHelp dlg = new DlgHelp(Principal.getInstance(),true);
         dlg.setVisible(true);
            
     }
}
